<template>
  <div class="panel">
    <div class="cert-table">
      <div class="table-header">
        <div class="header-cell">认证类型</div>
        <div class="header-cell">认证编号</div>
        <div class="header-cell">有效期</div>
        <div class="header-cell">状态</div>
      </div>
      <div class="table-content">
        <vue3-seamless-scroll
          :list="certListRef"
          :step="stepRef"
          :hover="hoverRef"
          :limitScrollNum="limitScrollNumRef"
          :wheel="wheelRef"
          :direction="directionRef"
          class="seamless-warp"
        >
          <div class="table-body">
            <div v-for="(item, index) in certList" :key="index" class="table-row">
              <div class="table-cell">{{ item.type }}</div>
              <div class="table-cell">{{ item.number }}</div>
              <div class="table-cell">{{ item.validity }}</div>
              <div class="table-cell">
                <span class="status" :class="item.status">{{ item.statusText }}</span>
              </div>
            </div>
          </div>
        </vue3-seamless-scroll>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'

// 模拟数据
const certList = [
  {
    type: '有机认证',
    number: 'ORG-2024-001',
    validity: '2024-01-01 至 2025-01-01',
    status: 'valid',
    statusText: '有效'
  },
  {
    type: '绿色食品',
    number: 'GREEN-2024-002',
    validity: '2024-02-15 至 2025-02-15',
    status: 'valid',
    statusText: '有效'
  },
  {
    type: '无公害认证',
    number: 'SAFE-2024-003',
    validity: '2024-03-01 至 2025-03-01',
    status: 'expiring',
    statusText: '即将到期'
  },
  {
    type: '地理标志',
    number: 'GEO-2024-004',
    validity: '2024-01-20 至 2025-01-20',
    status: 'valid',
    statusText: '有效'
  },
  {
    type: 'ISO认证',
    number: 'ISO-2024-005',
    validity: '2023-12-01 至 2024-12-01',
    status: 'expired',
    statusText: '已过期'
  }
]

const certListRef = ref(certList) as any
const stepRef = ref(0.5) as any
const hoverRef = ref(true) as any
const limitScrollNumRef = ref(2) as any
const wheelRef = ref(true) as any
const directionRef = ref<'up' | 'down' | 'left' | 'right'>('up') as any
</script>

<style scoped>
.panel {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.cert-table {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(51, 255, 208, 0.3);
  border-radius: 10px;
  background: rgba(51, 255, 208, 0.05);
  overflow: hidden;
}

.table-header {
  display: flex;
  background: rgba(51, 255, 208, 0.1);
  border-bottom: 1px solid rgba(51, 255, 208, 0.3);
  flex-shrink: 0;
  z-index: 1;
}

.header-cell {
  flex: 1;
  padding: 15px 10px;
  color: #33ffd0;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  min-width: 0;
}

.table-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.seamless-warp {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.table-body {
  display: flex;
  flex-direction: column;
}

.table-row {
  display: flex;
  border-bottom: 1px solid rgba(51, 255, 208, 0.1);
  background: rgba(51, 255, 208, 0.05);
}

.table-row:last-child {
  border-bottom: none;
}

.table-cell {
  flex: 1;
  padding: 15px 10px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.status.valid {
  background: rgba(103, 194, 58, 0.2);
  color: #67c23a;
}

.status.expiring {
  background: rgba(230, 162, 60, 0.2);
  color: #e6a23c;
}

.status.expired {
  background: rgba(245, 108, 108, 0.2);
  color: #f56c6c;
}
</style> 